<?php

namespace App\Repositories;

use App\Exceptions\BasicException;
use Illuminate\Support\Facades\Hash;
use function Matrix\add;    //引入hash

class GameJackpotRepository {

    /**
     * 获取新钓鱼奖池列表
     * @param $type
     * @return bool
     */
    public function newGiftList($type) {
        $newGiftList = app('model_game_jackpot')->where('type',$type)->orderBy('id', 'desc')->select('id','number','gift_id','ratio')->with('gift')->get()->toArray();
        return $newGiftList;
    }


    /**
     * 获取一条新钓鱼奖池信息
     * @param $where
     * @return bool
     * @throws BasicException
     */
    public function newOneGift($where) {
        $newOneGift = app('model_game_jackpot')->where($where)->first();
        if ($newOneGift) return $newOneGift;
        throw new BasicException(93081);
    }

    /*
     * 新增新钓鱼奖池
     * @param $param
     * @return bool
     * @throws BasicException
     *
     * */
    public function addNewPrize($param) {
        $addNewPrize = app('model_game_jackpot')->create($param);
        if ($addNewPrize) return $addNewPrize;
        throw new BasicException(93060);
    }

    /*
     * 编辑新钓鱼奖池
     * @param $param
     * @return bool
     * @throws BasicException
     * */
    public function saveNewPrize($param) {
        $saveNewPrize = app('model_game_jackpot')->where('id', $param['id'])->update($param);
        if ($saveNewPrize) return $saveNewPrize;
        throw new BasicException(93061);
    }

    /*
     * 删除新钓鱼奖池
     * @param $param
     * @return bool
     * @throws BasicException
     * */
    public function delNewPrize($param) {
        $delThisPrize = app('model_game_jackpot')->whereIn('id', $param)->delete();
        if ($delThisPrize) return $delThisPrize;
        throw new BasicException(93043);
    }
    /*
     * 新钓鱼一键修改礼物
     * @param $where
     * @param $param
     *
     * */
    public function editNewAllGifts($where,$param) {
        app('model_game_jackpot')->where($where)->update($param);
    }

}


?>